package com.share.order.api;

import com.share.common.core.domain.R;
import com.share.order.api.domain.OrderInfo;
import com.share.order.api.domain.OrderSqlVo;
import com.share.order.api.factory.RemoteOrderInfoFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;

/**
 * 远程调用订单服务接口
 *
 * @author YC
 */
@FeignClient(
        contextId = "remoteOrderInfoService",
        value = "share-order",
        fallbackFactory = RemoteOrderInfoFallbackFactory.class
)
public interface RemoteOrderInfoService {

    /**
     * 远程调用 - 获取未完成订单
     *
     * @param userId 用户ID
     * @return 未完成订单
     */
    @GetMapping("/orderInfo/getNoFinishOrder/{userId}")
    R<OrderInfo> getNoFinishOrder(@PathVariable("userId") Long userId);

    /**
     * 远程调用 - 根据订单号查询订单信息
     *
     * @param orderNo 订单编号
     * @return 订单信息
     */
    @GetMapping("/orderInfo/getByOrderNo/{orderNo}")
    R<OrderInfo> getByOrderNo(@PathVariable("orderNo") String orderNo);

    /**
     * 远程调用 - 传递过来sql语句，根据sql语句查询数据库得到报表数据
     *
     * @param orderSqlVo sql语句
     * @return 报表数据
     */
    @PostMapping("/orderInfo/getOrderCount")
    R<Map<String, Object>> getOrderCount(@RequestBody OrderSqlVo orderSqlVo);

}
